 <?php
 	header('Content-type:text/json');
 	require('../conn.php');
	require('../functions.php');

     $page=$_GET['page'];
     $uid=$_GET['uid'];
     $type=$_GET['type'];
	 //自定义列表文章显示数量
	if(is_numeric($config['ListArticle'])){
	    $max=$config['ListArticle'];
	    $min=($page-1)*$config['ListArticle'];
	}else{
	    $max=30;
	    $min=($page-1)*30;
	}

	if(is_numeric($type)==false){
	    $rows=$mysql->query("select `title`,`pic`,`pv`,`id` from `article` where `top`!='-1' order by -`top`,`id` desc limit {$min},{$max}");
	}else{
	    $rows=$mysql->query("select `title`,`pic`,`pv`,`id` from `article` where `type`='{$type}' and `top`!='-1' order by  -`top`,-`money` desc limit {$min},{$max}"); 
	}
	//金钱排序
	if($_GET['do']=='money'){
	    $rows=$mysql->query("select `title`,`pic`,`pv`,`id` from `article` where `top`!='-1' order by   -`top`,-`money`  limit {$min},{$max}");
	}
	//最热
	if($_GET['do']=='hot'){
	    $rows=$mysql->query("select `title`,`pic`,`pv`,`id` from `article` where `top`!='-1' order by -`top`,-`pv` limit {$min},{$max}");
	}
	//随机
	if($_GET['do']=='rand'){
	    $rows=$mysql->query("select `title`,`pic`,`pv`,`id` from `article` where `top`!='-1' order by -`top`,rand() limit {$min},{$max}");
	}
	//最新
	if($_GET['do']=='new'){
	    $rows=$mysql->query("select `title`,`pic`,`pv`,`id` from `article` where `top`!='-1' order by -`top`,`id` desc limit {$min},{$max}");
	}
    echo JSON($rows);
	$mysql->__destruct();
	$mysql->close();
 ?>